<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>hello vue</title>
<script src="vue.js"></script>
<style type="text/css">

	.v-enter,
	.v-leave-to{
		opacity: 0;
		transform: translateX(80px);
	}

	.v-enter-active,.v-leave-active{
		transition: all 0.5s ease;
	}



</style>
</head>
<body>




<div id="app">

	<a href="#" @click.prevent= " comName='login' " >登录</a>
	<a href="#" @click.prevent= " comName='register' " >注册</a>
	<a href="#" @click.prevent= " comName='three' " >第三个组件</a>
  
	<transition mode='out-in'>
<!-- 添加position可以防止溢屏，使网页不会有translateX(80px)作用时的滚动条出现 -->
		<component :is=" comName " style="position: absolute;"></component>
	</transition>




</div>










<br>


<script type="text/javascript">

Vue.component('login',{
	template:'<h3>登录组件</h3>'
})


Vue.component('register',{
	template:'<h3>注册组件</h3>'
})

Vue.component('three',{
	template:'<h3>第三个组件</h3>'
})





var app = new Vue({
  el: '#app',

  data: {
  	comName:'login' //代表component绑定的组件名称，方便切换组件
  },

  methods:{

  }

})





</script>

	
</body>
</html>